<?php

class Kieumau_Controller_Employer extends Kieumau_Controller_MainController
{
	public function init(){
		parent::init();
	}
	
	 public function sendEmail($mailto, $subject, $body) {
  		$authDetails = new Zend_Mail_Transport_Smtp ( 'smtp.gmail.com',
		    array ('auth' => 'login',
		      'username' => 'tmt@86solutions.com',
		      'password' => 'test12345',
		      'ssl' => 'SSL',
		      'port' => 465 ) );
		Zend_Mail::setDefaultTransport ( $authDetails );
  		$message = $subject;
  		$mail = new Zend_Mail ( 'UTF-8' );
  		$mail->setBodyHtml ( $body );
  		$mail->addTo ($mailto);
  		$mail->setSubject ( $subject );
  		try{
  			$mail->send();
  		}catch(Exception $ex)
  		{
  			echo '<br/> Send mail erorr, Error :'.$ex->getMessage();
  			exit;
  		}
    }
	
	public function test(){
		return "ok";	
	}
	
	// @author: Michael.Tran
	// $date: 02/06/2012
	// @function: createTemplate
	// @return: none
	public function createTemplate($dirTemplate, $sectionConfig = 'template', $fileConfig = 'template.ini' ){
    	try{
	    	$module =$this->getRequest()->getModuleName();//Get module name
	    	$baseUrl = $this->_request->getBaseUrl();//Get base url
	    	
	    	$filename = $dirTemplate . '/'.$module.'/' . $fileConfig;//Define the absolute path to template config's file [template.ini]
	    	$config = new Zend_Config_Ini($filename, $sectionConfig);
	    	$config = $config->toArray();
	    	$dirTemplateUrl = $baseUrl .'/public/'. $config['url'];//Define the relative path to template folder
	    	
// 	    	echo "<br/>".$this->view->dirCss = $dirTemplateUrl . $config['dirCss'];
// 	    	echo "<br/>".$this->view->dirImg = $dirTemplateUrl . $config['dirImg'];
// 	    	echo "<br/>".$this->view->dirJs = $dirTemplateUrl . $config['dirJs'];

	    	$this->view->dirCss = $dirTemplateUrl . $config['dirCss'];
	    	$this->view->dirImg = $dirTemplateUrl . $config['dirImg'];
	    	$this->view->dirJs = $dirTemplateUrl . $config['dirJs'];
	    	
	    	$option = array('layout'=> $config['layout'],
	    			'layoutPath'=>PUBLIC_PATH.'/'.$config['url']);
	    	Zend_Layout::startMvc($option);//Start the template layout
    	}catch(Exception $ex){
    		echo '<br/>Can not render template for '.$module.' <br/>Error: '.$ex->getMessage();
    		exit();
    	}
    }
}
